//
//  NSObject+Blocks.h
//  PSFoundation
//
//  Created by Peter Steinberger on 24.10.10.
//  Copyright 2010 Peter Steinberger. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

typedef void (^NSObjectPerformBlock)(id userObject);
@interface NSObject (Blocks)

- (void)performAfterBlock:(dispatch_block_t)block after:(float)time;


- (void)performBlock:(void (^)(void))block afterDelay:(NSTimeInterval)delay;


- (void)performAfterDelay:(float)delay thisBlock:(void (^)(BOOL finished))completion;


- (void)performBlockInBackground:(NSObjectPerformBlock)performBlock completion:(NSObjectPerformBlock)completionBlock userObject:(id)userObject;

- (void)countdDown:(NSInteger)timeOut Done:(dispatch_block_t)done Time:(void(^)(NSInteger Count))time NS_DEPRECATED_IOS(8_0,10_0,"iOS8.0之后使用");

- (void)performOnMainThread:(void(^)(void))block wait:(BOOL)wait;
- (void)performAsynchronous:(void(^)(void))block;
- (void)performAfter:(NSTimeInterval)seconds block:(void(^)(void))block;

@end



@interface NSObject (Category)

/**
 * 在主线程中运行某个方法，可带两个参数
 * @param aSelector 方法名（指针）
 * @param arg1 参数一
 * @param arg2 参数二
 * @param wait 是否等待执行完成
 */
- (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg1 withObject:(id)arg2 waitUntilDone:(BOOL)wait;

/**
 * 在后台（子）线程中运行某个方法，可带两个参数
 * @param aSelector 方法名（指针）
 * @param arg1 参数一
 * @param arg2 参数二
 */
- (void)performSelectorInBackground:(SEL)aSelector withObject:(id)arg1 withObject:(id)arg2;


@end




